var TChannelAsThrift = require('tchannel/as/thrift');
var TChannel = require('tchannel');
var fs = require('fs');
var path = require('path');



var client = TChannel();
var echoChannel = client.makeSubChannel({
    serviceName: 'process_config_servic1',
    peers: ['172.30.32.88:5011']
});
var tchannelAsThrift = TChannelAsThrift({
    channel: echoChannel,
    entryPoint: path.join(__dirname, 'thrift/core_order.thrift')
});

tchannelAsThrift.request({
    serviceName: 'core_sample_service',
    timeout: 10000,
    headers: {
        cn: 'echo'
    },
    hasNoParent: true
}).send('OrderSampleService::GetOrderSampleJson', {
    someHeader: 'headerValue'
}, {
    value: 'some-string'
}, onResponse);

function onResponse(err, res) {
    if (err) {
        console.log('got error', err);
    } else {
        console.log('got response', res);
    }
    client.close();
}
